package com.datalayer.testclasses;

import com.datalayer.annotations.*;
import com.datalayer.utils.AssociationType;

import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;

@SuppressWarnings("ALL")
@Entity(tableName = "Task")
public class Task {
    int numar;
    Collection<Angajat> angajati = new ArrayList<Angajat>();

    public Task() {
    }

    public Task(int numar) {
        this.numar = numar;
    }

    @Direction("get")
    @Association(type = AssociationType.MANY2MANY, joins = {
            @Join(fieldName = "angajati", insideName = "numar", foreignName = "id")
    })
    public Collection<Angajat> getAngajati() {
        return angajati;
    }

    @Direction("get")
    @Constraint(constraintName = "primary key")
    @Attribute(fieldName = "numar", attributeName = "numar", type = "int")
    public int getNumar() {
        return numar;
    }

    @Direction("set")
    @Association(type = AssociationType.MANY2MANY, joins = {
            @Join(fieldName = "angajati", insideName = "numar", foreignName = "id")
    })
    public void setAngajati(LinkedList<Angajat> angajati) {
        this.angajati = angajati;
    }

    @Direction("set")
    @Attribute(fieldName = "numar", attributeName = "numar", type = "int")
    public void setNumar(int numar) {
        this.numar = numar;
    }

    @Direction("set")
    @Association(type = AssociationType.MANY2MANY, joins = {
            @Join(fieldName = "angajati", insideName = "numar", foreignName = "id")
    })
    public void setAngajati(Collection<Angajat> angajati) {
        this.angajati = angajati;
    }

    @Direction("add")
    @Association(type = AssociationType.MANY2MANY, joins = {
            @Join(fieldName = "angajati", insideName = "numar", foreignName = "id")
    })
    public void addAngajati(Angajat angajat) {
        angajati.add(angajat);
    }
}